<?php /*a:2:{s:69:"C:\Users\Administrator\Desktop\kitecms\app\admin\view\admin\user.html";i:1572833562;s:72:"C:\Users\Administrator\Desktop\kitecms\app\admin\view\common\header.html";i:1572833562;}*/ ?>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加管理员','<?php echo url("addUser"); ?>')"><i class="layui-icon"></i>添加管理员</button>
    </xblock>
    <table class="layui-table layui-form" id="list" lay-filter="table"></table>

</div>
<script type="text/html" id="titleTpl">
    {{# if(d.id == 1 && <?php echo session('aid'); ?> != 1){ }}
    <a class="layui-btn layui-btn-xs layui-btn-disabled">编辑</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-xs" onclick="x_admin_show('编辑管理员','<?php echo url('editUser'); ?>?id={{d.id}}')" >编辑</a>
    {{# } }}
    {{# if(<?php echo session('aid'); ?> == d.id || d.id == 1){ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled">删除</a>
    {{# }else{ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# } }}
</script>
<script>
    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.get("<?php echo url('del'); ?>",{id:id},function (res) {
                if (res.success){
                    $(obj).parents("tr").remove();
                    layer.msg(res.msg,{icon:1,time:1000});
                }else{
                    layer.msg(res.msg,{icon:2,time:1000});
                }
            });

        });
    }
    layui.use('table', function(){
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#list'
            ,url: "<?php echo url('user'); ?>" //数据接口
            ,method:'post'
            ,cols: [[ //表头
                {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
                ,{field: 'real_name', title: '用户名', width:150}
                ,{field: 'nickname', title: '昵称', width:150}
                ,{field: 'role_name', title: '角色', width:150}
                ,{field: 'email', title: '邮箱', width: 180}
                ,{ title: '操作', width: 180,toolbar:'#titleTpl'}
            ]]
        });

        table.on('tool(table)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）

            if(layEvent === 'del'){ //删除
                layer.confirm('真的删除该管理员吗？', function(index){
                    var load = layer.load(1)
                    $.post("<?php echo url('delUser'); ?>",{id:data.id},function (res) {
                        layer.close(load);
                        if (res.success){
                            layer.msg(res.msg,{icon:1},function () {
                                obj.del();
                                layer.close(index);
                            })
                        } else{
                            layer.msg(res.msg,{icon:2})
                        }
                    });
                });
            }
        });

    });
</script>
</body>

</html>